﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace ReconUI
{
    public partial class ReconSite : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {          
          
            if(((UserVO)Session["CurrentUserVO"]) !=null)
            {
                try
                {
                    DateTime currentTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
                    lblDateTime.Text = "Welcome " + ((UserVO)Session["CurrentUserVO"]).userName + "! " + currentTime.ToString("MMMM d yyyy, hh:mm tt IST");
                }
                catch (TimeZoneNotFoundException exc)
                {
                    DateTime currentTime = DateTime.UtcNow.AddHours(5).AddMinutes(30);
                    lblDateTime.Text = "Welcome " + ((UserVO)Session["CurrentUserVO"]).userName + "! " + currentTime.ToString("MMMM d yyyy, hh:mm tt IST");
                }

                if (!IsPostBack)
                {
                    //if (Session["IsMainMenuLoaded"] == null)
                    //{
                    MenuManager objMenuManager = new MenuManager();
                    objMenuManager.populateMenu(mnReconEngine, ((UserVO)Session["CurrentUserVO"]).roleId);
                    Session["IsMainMenuLoaded"] = true;
                    //}
                    //mnReconEngine.Visible = true;
                }

            }
            else
            {
               // lblUserName.Text = "Welcome Guest!";
                DateTime currentTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
                lblDateTime.Text = "Welcome Guest!  " + currentTime.ToString("MMMM d yyyy, hh:mm tt IST");
                lgsCurrent.Visible = false;
                mnReconEngine.Visible = false;
            }
           // lblDateTime.Text = DateTime.Now.ToString();


        }

        protected void lgsCurrent_LoggedOut(object sender, EventArgs e)
        {
            Session.Abandon();
            FormsAuthentication.SignOut();
        }
    }

    
}